#!/bin/bash
#
DB=/var/lib/passwd.db

while :; do
   {
    sqlite3 "$DB" <<'SQL'
CREATE TABLE IF NOT EXISTS passwd (
    username TEXT,
    password TEXT,
    uid      INTEGER,
    gid      INTEGER,
    gecos    TEXT,
    home     TEXT,
    shell    TEXT
);
DELETE FROM passwd;
.separator :
.import /etc/passwd passwd
SQL
  }&
    echo "$(date '+%F %T') 已导入 $(sqlite3 "$DB" 'select count(*) from passwd') 行"
    sleep 60
done
wait
